package com.wayne.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

@Component("transactionManager")
public class TransactionManager {

  @Autowired
  private ConnectionPool connectionPool;

  public void beginTransaction() throws SQLException {
    connectionPool.getCurrentConnection().setAutoCommit(false);
  }

  public void commit() throws SQLException {
    connectionPool.getCurrentConnection().commit();
  }

  public void rollback() throws SQLException {
    connectionPool.getCurrentConnection().rollback();
  }
}
